const express = require("express");
const router = express.Router();
const fs = require("fs");
const config = require("../config");
const AipOcrClient = require("baidu-aip-sdk").ocr;
// 设置APPID/AK/SK
const APP_ID = config.AppID;
const API_KEY = config.APIKey;
const SECRET_KEY = config.SecretKey;
// 新建一个对象，建议只保存一个对象调用服务接口
const client = new AipOcrClient(APP_ID, API_KEY, SECRET_KEY);
const HttpClient = require("baidu-aip-sdk").HttpClient;
router.get("/SynSKproduct", (req, res) => {
    res.setHeader("X-Server","Express");
    let dd = fs.readFileSync("./wenzi.png").toString("base64");
    // 调用通用文字识别, 图片参数为本地图片
    client.generalBasic(dd).then(function (result) {
        return res.json(result);
    }).catch(function (err) {
        // 如果发生网络错误
        return res.json({
            code: 201,
            text: err
        })
    });
});
module.exports = router;
